﻿@model Gagnatek.WebSite.Models.Loans
@{
    ViewBag.Title = "Create";
}
<h2>
    Réserver un article</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm(new { loans = Model, mediaId = ViewBag.mediaId, userId = ViewBag.userId }))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <div class="editor-label">
            Date de réservation
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.pickedAt)
            @Html.ValidationMessageFor(model => model.pickedAt)
        </div>
        <div class="editor-label">
            Date de retour
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.returnedAt)
            @Html.ValidationMessageFor(model => model.returnedAt)
        </div>
        @if (User.IsInRole("Owner"))
        {
            <div class="editor-label">
                @Html.LabelFor(model => model.user_id, "Users")
            </div>
            <div class="editor-field">
                @Html.DropDownList("user_id", String.Empty)
                @Html.ValidationMessageFor(model => model.user_id)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.media_id, "Medias")
            </div>
            <div class="editor-field">
                @Html.DropDownList("media_id", String.Empty)
                @Html.ValidationMessageFor(model => model.media_id)
            </div>
        }
        <p>
            <input type="submit" value="Réserver" />
        </p>
    </fieldset>
}
<div>
    @Html.ActionLink("Back to List", "Index", "Home")
</div>
